package com.briup.demo.service.impl;

import com.briup.demo.bean.User;
import com.briup.demo.bean.extend.UserExtend;
import com.briup.demo.service.IUserService;
import com.briup.demo.dao.UserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class UserServiceImpl implements IUserService {
@Resource
    private UserMapper userMapper;
    @Override
    public List<User> findAll() {
        return userMapper.selectAll();
    }

    @Override
    public void saveOrupdate(User user) {
        if(user.getId()!=null){
            userMapper.update(user);
        }
        else {
            userMapper.insert(user);
        }
    }

    @Override
    public void delete(Long id) {
        userMapper.delete(id);
    }

    @Override
    public List<UserExtend> findAllWithRole() {
        return userMapper.selectAllWithRole();
    }
}
